|
|
Chris Huff wrote:
>
> The use of VLength and VInverseScaleEq instead of VNormalize wasn't the
> bug I was talking about...the vector passed to the function is being
> normalized, when the function should create it's own copy. Since a
As far as my understanding of C and the workings of the POV-type
VECTOR go, this should *not* modify the "real" V1, since the value is
passed on the stack. The V1 in the function gets modified, but *not*
the parameter that is passed, example:
int ParamFunction(int i)
{
i = i/2; // modify parameter
return i; // and return the result
}
void TestParam(void)
{
int x;
x = 5;
printf("%d\n",ParamFunction(x)); // prints "2"
printf("%d\n",x); // prints "5", i.e. "x"
}
This prints:
2 5
i.e. internal to the function, the parameter "i" gets modified,
but this does *not* modify the "calling" parameter x.
This is guaranteed by the C standard.
Or is the "VECTOR" type some hidden pointer?
Markus
Post a reply to this message
|
|